$(window).load(function(){
    // 点击头部搜索类型下拉框 显示下拉框选项
    $(document).on("click","#searchOption",function(){



        var panelObj = $("#searchPanel");
        if(panelObj.css("display") != "none"){
            panelObj.hide();
        }else{
            // 设置默认选中类型样式
            var searchType = $("#hdnSearchType").val();
            $("#searchPanel li").removeClass("searchhover");
            $("#searchPanel li:eq("+searchType+")").addClass("searchhover");
            // 显示下拉菜单项
            panelObj.show();
        }
    });

    // 设置头部搜索类型下拉项鼠标悬停样式
   $(document).on("hover","#searchPanel li",function(){
        $("#searchPanel li").removeClass("searchhover");
        $(this).addClass("searchhover");
    },function(){
        $(this).removeClass("searchhover");
    });

    // 选择头部搜索类型下拉项
    $(document).on("click","#searchPanel li",function(){

        var spanValue = $(this).text() + '<font class="imageSite"><img src="/quanliadmin/docroot/images/comm/selects.jpg"></font>';
        $("#searchOption").html( spanValue );
        var departmentID = $(this).attr('departmentID');
        if( departmentID == 0 ){
            $("#departmentID").val(departmentID);
            $("#departmentName").val('');//当前选中部门赋值给input
        }else{
            $("#departmentID").val(departmentID);
            $("#departmentName").val($(this).text());//当前选中部门赋值给input
        }

        $("#searchPanel").hide();
        // 保存当前所选类型(0:Product；1:Seller)
        $("#hdnSearchType").val($("#searchPanel li").index($(this)));
    });

    /* 点击除下拉菜单项外任意区域，关闭自定义下拉菜单项 */
    $(document).click(function(event) {
        if ($(event.target).attr("id") != "searchOption") {
            $("#searchPanel").hide();
        }
    });



    // 点击头部搜索类型下拉框 显示下拉框选项
    $(document).on("click","#searchOptions",function(){
        var panelObj = $("#searchPanels");
        if(panelObj.css("display") != "none"){
            panelObj.hide();
        }else{
            // 设置默认选中类型样式
            var searchTypes = $("#hdnSearchTypes").val();
            $("#searchPanels li").removeClass("searchhover");
            $("#searchPanels li:eq("+searchTypes+")").addClass("searchhover");
            // 显示下拉菜单项
            panelObj.show();
        }
    });



    // 设置头部搜索类型下拉项鼠标悬停样式
    $(document).on("mouseover","#searchPanels li",function(){
        $("#searchPanels li").removeClass("searchhover");
        $(this).addClass("searchhover");
    });
    $(document).on("mouseout","#searchPanels li",function(){
        $(this).removeClass("searchhover");
    });



    // 选择头部搜索类型下拉项
    $(document).on("click","#searchPanels li",function(){
        var spanValues = $(this).text() + '<font class="imageSites"><img src="/quanliadmin/docroot/images/comm/selects.jpg"></font>';
        $("#searchOptions").html(spanValues);
        var departmentID = $(this).attr('departmentID');
        if( departmentID == 0 ){
            $("#search_departmentID").val(departmentID);
            //$("#departmentName").val('');//当前选中部门赋值给input
        }else{
            $("#search_departmentID").val(departmentID);
            //$("#departmentName").val($(this).text());//当前选中部门赋值给input
        }

        $("#searchPanels").hide();
        // 保存当前所选类型(0:Product；1:Seller)
        $("#hdnSearchTypes").val($("#searchPanel li").index($(this)));
    });


    /* 点击除下拉菜单项外任意区域，关闭自定义下拉菜单项 */
    $(document).click(function(event) {
        if ($(event.target).attr("id") != "searchOption") {
            $("#searchPanel").hide();
        }
    });

});